<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.GregorianCalendar,java.util.Calendar,java.util.regex.*,java.util.*" %>
<%@page import="java.rmi.registry.LocateRegistry"%>
<%@page import="java.rmi.registry.Registry"%>
<%@page import="java.util.ArrayList"%>
<%@page import="rmi.*" %>
<%@page import="data.*" %>
<jsp:useBean id="manager" scope="session" class="manager.Manager" />

<%
Iterator it ;
ArrayList<Ordonnance> list=new ArrayList<Ordonnance>() ;
int nbOrdonnance=0;
String jour="";
String mois="";
String annee="";

nbOrdonnance=manager.getServeurRmi().nbEnregistrements(Ordonnance.class) ;
String numero_securite_sociale=request.getParameter("numero_securite_sociale") ;
Patient patient=manager.getServeurRmi().getPatient(numero_securite_sociale) ;

list=manager.getServeurRmi().listerOrdonnances(patient.getNumero_securite_sociale_patient(),"",0,nbOrdonnance) ;
it=list.iterator() ;
%>
	<div id="action">
		<table style="width:90%;height:100%;margin-left:5%;">
			<tr>
				<td style="text-align:left;font-weight:bold;color:white;text-decoration:underline;"><a href="../ordonnance/creer_ordonnance.jsp?id_patient=<%= patient.getNumero_securite_sociale_patient() %>" >Créer une ordonnance</a></td>
				<td style="width:35px;"><a href="modifier_patient.jsp?numero_securite_sociale=<%= numero_securite_sociale%>"><img src="../images/design/update.png" style="width:30px;"/></a></td>
				<td style="width:35px;"><a href="supprimer_patient.jsp?numero_securite_sociale=<%= numero_securite_sociale %>"><img src="../images/design/delete.png" style="width:30px;"/></a></td>
			</tr>
		</table>
	</div>
	
	<h2>Informations personnelles</h2>
	<div id="contenu_style2_haut">
</div>
<div id="contenu_style2_centre">
	<table>
			<tr>
				<td style="font-weight:bold;font-size:14px;border-bottom:1px solid #163aa2;"><%= patient.getNumero_securite_sociale_patient() %> | <%= patient.getNom_patient()%> <%= patient.getPrenom_patient()%></td>
				<td style="border-bottom:1px solid #163aa2;">&nbsp;</td>
			</tr>
			<tr>
				<td><img src="../images/patient/<%= patient.getPhoto_patient() %>" style="width:150px;"/></td>
				<td>
					<table style="width:100%;margin:0;">
						<tr>
							<td style="font-weight:bold;text-decoration:underline;">Suivi :</td>
							<td>&nbsp;</td>
						</tr>
						<tr>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
						</tr>
						<tr>
							<td>Sexe :</td>
							<td><%= patient.getSexe_patient() %></td>
						</tr>
<%
						jour=patient.getDate_naissance_patient().substring(8,10);
						mois=patient.getDate_naissance_patient().substring(5,7);
						annee=patient.getDate_naissance_patient().substring(0,4);
%>						
						<tr>
							<td>Date de naissance :</td>
							<td><%= jour %>/<%= mois %>/<%= annee %></td>
						</tr>
						<tr>
							<td>Taille :</td>
							<td><%= patient.getTaille_patient() %></td>
						</tr>
						<tr>
							<td>Poids :</td>
							<td><%= patient.getPoids_patient() %></td>
						</tr>
						<tr>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
						</tr>
					</table>	
				</td>
			</tr>
			<tr>
				<td>
					<table style="width:100%;margin:0;">
						<tr>
							<td style="font-weight:bold;text-decoration:underline;">Coordonnées :</td>
							<td>&nbsp;</td>
						</tr>
						<tr>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
						</tr>
						<tr>
							<td>Adresse :</td>
							<td><%= patient.getAdresse_patient() %></td>
						</tr>
						<tr>
							<td>Code postal :</td>
							<td><%= patient.getCode_postal_patient() %></td>
						</tr>
						<tr>
							<td>Ville :</td>
							<td><%= patient.getVille_patient() %></td>
						</tr>
						<tr>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
						</tr>
					</table>	
				</td>
				<td>
					<table style="width:100%;margin:0;">
						<tr>
							<td style="font-weight:bold;text-decoration:underline;">Contacts :</td>
							<td>&nbsp;</td>
						</tr>
						<tr>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
						</tr>
						<tr>
							<td>Numéro téléphone :</td>
							<td><%= patient.getNumero_telephone_patient() %></td>
						</tr>
						<tr>
							<td>Numéro portable :</td>
							<td><%= patient.getNumero_portable_patient() %></td>
						</tr>
						<tr>
							<td>Email :</td>
							<td><%= patient.getEmail_patient() %></td>
						</tr>
						<tr>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
						</tr>
					</table>	
				</td>
			</tr>
	</table>
</div>
<div id="contenu_style2_bas">
</div>
<h2>Historique des ordonnances</h2>
<div id="contenu_style2_haut">
</div>
<div id="contenu_style2_centre">
<%
if(list.size()==0) {
%>
	<table>
		<tr>
			<td style="text-align:center;font-weight:bold;font-size:14px;">Aucune ordonnance enregistrée pour ce patient</td>
		</tr>
	</table>
<%	
}else{
%>
	<table>
		<tr>
			<th>Date</th>
			<th>Médecin</th>
			<th>Visualiser</th>
		</tr>
<%
	while(it.hasNext()) {
		Ordonnance ordonnance=(Ordonnance) it.next() ;
		Medecin medecin=manager.getServeurRmi().getMedecin(ordonnance.getId_medecin());
		jour=ordonnance.getDate_ordonnance().substring(8,10);
		mois=ordonnance.getDate_ordonnance().substring(5,7);
		annee=ordonnance.getDate_ordonnance().substring(0,4);
	
		
%>
		<tr>
			<td style="text-align:center;font-weight:bold;"><%= jour %>/<%= mois %>/<%= annee %></td>
			<td style="text-align:center;"><%= medecin.getNom_medecin() %> <%= medecin.getPrenom_medecin() %></td>
			<td style="text-align:center;"><a href="/cabinet_medical/PDFOrdonnance?id_ordonnance=<%= ordonnance.getId_ordonnance() %>" target="_blank"><img src="../images/design/pdf.PNG" style="width:40px;" /></a></td>
		</tr>
<%		
	}
%>
	</table>
<%	
}
%>
</div>
<div id="contenu_style2_bas">
</div>




